<?php
namespace Admin\Controller;

class IndexController extends CommonController
{


    public function index()
    {
        $this->display();
    }


    public function pass(){
        $this->display('pass');
    }

//修改密码方法
    public function edit(){
		$User = D("User"); // 实例化User对象
        $res=$User->find($_SESSION[C('USER_AUTH_KEY')]);
        $password_o = md5(C('AUTH_CODE') . md5(I('password_o'))); //获取提交过来的原密码 并进行MD5加密
        $password = md5(C('AUTH_CODE') . md5(I('password'))); //获取提交过来的密码 并进行MD5加密
        if($res['password'] == $password_o){
            $duser=array(
                'id'=>$_SESSION[C('USER_AUTH_KEY')],
                'password'=>$password,
            );
            if($User->save($duser)){
                $data=[
                    'status'=>1,
                    'info'=>'密码修改成功！'
                ];
            }else{
                $data=[
                    'status'=>0,
                    'info'=>'密码修改失败！'
                ];
            }
        }else{
            $data=[
                'status'=>0,
                'info'=>'原密码输入有误！'
            ];
        }
        $this->ajaxReturn($data);
	}


    public function info()
    {
        $this->display();
    }
}